﻿// -----------------------------------------------------------------------
// <copyright file="Class1.cs" company="Hewlett-Packard">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex3.Logic
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public static class Common
    {
        // consts
        public const string k_Circles = @"Circles.dat";
        public const string k_FileNameRankPhotos = @"Rank.dat";

        public enum Stars
        {
            NONE = 0,
            ONE = 1,
            TWO,
            THREE,
            FOUR,
            FIVE
        }

        public static void FindInListBox(ListBox i_ListBox, TextBox i_TextBoxSearch)
        {
            i_ListBox.ClearSelected();
            int foundIdx = i_ListBox.FindString(i_TextBoxSearch.Text);
            if (foundIdx > -1)
            {
                // if an exact match, select the match
                if (i_TextBoxSearch.Text.ToLower() ==
                    i_ListBox.Items[foundIdx].ToString().ToLower())
                {
                    i_ListBox.SelectedIndex = foundIdx;
                }

                // scroll to the closest match:
                i_ListBox.TopIndex = foundIdx;
                i_ListBox.SetSelected(foundIdx, true);
            }
        }
    }
}
